package cn.xspace.wnx.entity;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
import com.xspace.android.xafcommon.util.XmlUtils;

/**
 * Created by liuchen on 2017/1/11.
 */
@XStreamAlias("message")
public class XmppBean {
    @XStreamAsAttribute
    public String id = "";
    @XStreamAsAttribute
    public String to = "";
    @XStreamAsAttribute
    public String from = "";

    @XStreamAlias("body")
    public String body;
    @XStreamAlias("thread")
    public String thread;

    @XStreamAlias("msgInfo")
    public XmppMsgInfo msgInfo;

    @XStreamAlias("properties")
    public XmppPropertys properties;

    public static void main(String[] args) {
        String xmlStr = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                "\n" +
                "<message id=\"K4TFU-157\" to=\"e133438d-4679-4d27-9133-587c472ceebc@42.120.48.75\" from=\"ctnqadmin@localhost/pc0\">\n" +
                "  <body>{\"dept_id\":\"\",\"dept_name\":\"\",\"logo\":\"\",\"msg_type\":\"\",\"msg_logo\":\"\",\"msg_jsonbody\":\"【在线农技员】在 2017-01-11 14:01:59 问题 [null] 有新回复,问题ID[ab06edc672fe4d878a2624027967f425]{e133438d-4679-4d27-9133-587c472ceebc@ee36fdbd-a844-4292-8fab-299a569ce7b9}\",\"msg_body\":\"\",\"biz_code\":\"\"}</body>\n" +
                "  <thread>vt3Dr6</thread>\n" +
                "  <msgInfo xmlns=\"jabber:client\">\n" +
                "    <msgLogo/>\n" +
                "    <msgId>395ea30a-a97e-40ee-bc13-b0d4a80d3a0f</msgId>\n" +
                "    <msgType>QACWEB</msgType>\n" +
                "    <senderPhone/>\n" +
                "    <senderId/>\n" +
                "    <platForm>QACWEB</platForm>\n" +
                "    <senderName/>\n" +
                "    <sendDeptName>问答小助手</sendDeptName>\n" +
                "    <msgSequenceId>87877</msgSequenceId>\n" +
                "    <bizCode>null</bizCode>\n" +
                "    <sendDeptId>QACWEB</sendDeptId>\n" +
                "    <sendTime>20170111140159</sendTime>\n" +
                "    <logo>null</logo>\n" +
                "    <msgChannel/>\n" +
                "  </msgInfo>\n" +
                "  <properties xmlns=\"http://www.jivesoftware.com/xmlns/xmpp/properties\">\n" +
                "    <property>\n" +
                "      <name>params</name>\n" +
                "      <value type=\"string\">QACWEB,13608330019,87877,20170111140159,,QACWEB,QACWEB,问答小助手,,395ea30a-a97e-40ee-bc13-b0d4a80d3a0f</value>\n" +
                "    </property>\n" +
                "  </properties>\n" +
                "</message>";
        XmppBean xmppBean = XmlUtils.toBean(XmppBean.class, xmlStr.getBytes());
        System.out.println(xmppBean.body.toString());
        System.out.println(xmppBean.id);
        System.out.println(xmppBean.to);
        System.out.println(xmppBean.from);
        System.out.println(xmppBean.msgInfo.msgLogo);


    }

}
